<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <title>抱团</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no,minimal-ui,viewport-fit=cover" />
    <meta name="keywords" content="抱团">
    <meta name="description" content="抱团">
    <script type="text/javascript" src="js/base.js" charset="UTF-8"></script>
    <!-- <link rel="stylesheet" type="text/css" href="css/theme-chalk/index.css"> -->
    <!-- <link rel="stylesheet" type="text/css" href="css/swiper-bundle.min.css"> -->
    <link rel="stylesheet" type="text/css" href="css/base.css">
    <link rel="stylesheet" type="text/css" href="css/style.css">
    <script type='text/javascript' src="js/jquery.min.js" charset="UTF-8"></script>
    <!-- <script type='text/javascript' src="js/html2canvas.min.js" charset="UTF-8"></script> -->
    <script type="text/javascript" src="js/layer/layer.js" charset="UTF-8"></script>
    <script type="text/javascript" src="js/vue.js" charset="UTF-8"></script>
    <script type="text/javascript" src="js/axios.min.js" charset="UTF-8"></script>
    <!-- <script type='text/javascript' src="js/elementui.min.js" charset="UTF-8"></script> -->
    <!-- <script type='text/javascript' src="js/swiper-bundle.min.js" charset="UTF-8"></script> -->
    <script type='text/javascript' src="../common/js/helper.js" charset="UTF-8"></script>
</head>
<body>
    <div class="page mysy" id="app" v-if="loaded==true">
        <!-- 用户信息 -->
        <div class="user">
            <img class="img" :src="user_info.avatar_url" alt="">
            <div class="name">{{user_info.nickname}} 的金库</div>
        </div>
        <!-- 提现信息 -->
        <div class="txBox">
            <div class="top" v-if="!txFlag">
                <div class="til">
                    <div class="l"><em>可提现金额 :</em><span>{{shouyidata.un_settled}}</span></div>
                    <div class="r"><em>暂存提现:</em><span>{{shouyidata.temp}}</span>
                        <div class="icon" @click="alertBoxToggle">
                            <div class="alertBox">
                                <div class="des">暂存提现为用户购买未消费的金额，用户消费后可提现。</div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="tx">
                    <div class="input">
                        <input type="text" @change="checkInput" v-model="tx" placeholder="请输入提现金额">
                        <span @click="txall">全部提现</span>
                    </div>
                    <div :class="['btn',{'allow':tx!='' && tx!=0}]" @click="gotx">立即提现</div>
                </div>
            </div>
            <div v-if="txFlag" class="top top_">
                <div class="img"></div>
                <div class="des">
                    <div>提交成功</div>
                    <div>提现将在一个工作日内到您微信零钱中！</div>
                </div>
            </div>
            <div class="bottom">
                <div class="item">满足50元即可提现，一个工作日内到账！</div>
                <div class="item">首次提现请添加微信“baotuan00001”发送“我要提现”的 指令即可快速到账</div>
                <div class="item">暂存提现为用户购买未消费的金额，用户消费后可提现。</div>
            </div>
        </div>
        <!-- 提现记录 -->
        <div class="sylist">
            <div class="til">提现记录</div>
            <div class="txList" v-if="listdata.length>0">
                <div class="item" v-for="(item,index) in listdata" :key="index">
                    <div class="l">{{item.created_at}}</div>
                    <div class="r">提现 {{item.withdraw_amount}} 元</div>
                </div>
            </div>
            <div class="empty" v-if="listdata.length==0">
                <div class="img"><img src="images/search-empty.png" alt=""></div>
                <p>暂无提现记录</p>
            </div>
        </div>
    </div>

</body>
<script>
    new Vue({
        el: '#app',
        data() {
            return {
                user_info:{},
                loaded:false,
                shouyidata:'',
                tx:'',
                listdata:'',
                txFlag :false,
            }
        },
        mounted() {
            var that=this;
            
            var user_info=JSON.parse(getCookie("user_info"));
            if(!user_info){
                that.isLogin=false;
            }else{
                that.isLogin=true;
                that.user_info=user_info;
            }
            that.getdata();
        },
        methods: {
            getdata:function(){
                var that=this;
                that.page=1;
                var ready1=false,ready2=false;
                var load=setInterval(()=>{
                    if(ready1==true && ready2==true){
                        that.loaded=true;
                        clearInterval(load)
                    }
                },100)
                //查询收益概况
                talent_get('profits/total_summary').then(res => {
                    // console.log(res);
                    that.shouyidata=res;
                    ready1=true;
                })
                //查询提现记录
                talent_get('withdraws').then(res => {
                    console.log(res);
                    // that.has_more=res.has_more;
                    that.listdata=res;
                    ready2=true;
                })
            },
            gotx:function(){
                var that=this;
                if($('.page.mysy .txBox .tx .btn').hasClass('allow')){
                    talent_post('withdraws',{
                        "withdraw_amount": that.tx,
                    }).then(res => {
                        console.log(res)
                        that.txFlag=true;
                    })
                }
            },
            alertBoxToggle:function(){
                var that=this;
                $('.alertBox').fadeToggle(500);
            },
            checkInput:function(){
                var that=this;
                that.tx=that.tx.replace(/[^\d]/g,"");
            },
            txall:function(){
                var that=this;
                that.tx=that.shouyidata.un_settled;
            },
        }
    });
</script>

</html>